import React, { PropTypes } from 'react';
import style from './index.less'
import {Table} from 'antd'


/**
 * TableListTransform 表格列表(头列转换)
 */
const TableListTransform= ({
    fieldList = [],
    list = []
}) => {
    // 表格数据设置
    const dataSource = []
    fieldList.map((item, index) => {
        const obj = {}
        list.map((it, i) => {
            obj.id = item.id
            obj.name = item.name
            obj[`${it.id}`] = it[item.id]
        })
        dataSource.push(obj)
    })
    // 表头设置
    const columns = []
    list.map(item => {
        columns.push({
            title: item.name,
            dataIndex: item.id,
            key: item.id,
        })
    })

    return <Table dataSource={dataSource} columns={columns} rowKey='name' pagination={false} />
}
export default TableListTransform;
